package com.wwp.wkb.ui.web;

import android.text.TextUtils;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
import android.webkit.WebView;

import com.wwp.wkb.R;
import com.wwp.wkb.base.BaseActivity;

import butterknife.BindView;

public class WebFileActivity extends BaseActivity {
    @BindView(R.id.webview)
    WebView webView;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_web_view;
    }

    @Override
    protected void setUpView() {
        String title = getIntent().getStringExtra("title");
        if (TextUtils.isEmpty(title)) {
            setTitleBarTitle("详情");
        } else {
            setTitleBarTitle(title);
        }

        //"file:///android_asset/mile_user.html"
        String path = getIntent().getStringExtra("path");
        if (TextUtils.isEmpty(path)) {
            return;
        }

        WebSettings webSettings = webView.getSettings();
        webSettings.setLoadWithOverviewMode(true);
        webSettings.setUseWideViewPort(true);
        //支持JavaScript
        webSettings.setJavaScriptEnabled(true);
        //自适应屏幕
        webSettings.setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
        webSettings.setLoadWithOverviewMode(true);
        //设置可以支持缩放
        webSettings.setSupportZoom(true);
        //扩大比例的缩放
        webSettings.setUseWideViewPort(true);
        webView.loadUrl(path);
    }
}
